package com.grass.p019lv.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import com.grass.p019lv.event.EventBusEvent;
import com.grass.p019lv.event.EventBusUtils;
import java.util.Objects;

/* renamed from: com.grass.lv.service.PlayerReceiver */
public class PlayerReceiver extends BroadcastReceiver {
    private static final String CHANNEL_ID = "channel_001";
    private static final String GROUP_ID = "group_001";
    public static final String NOTIFY_CLOSE = "pure_music.kunminx.close";
    public static final String NOTIFY_NEXT = "pure_music.kunminx.next";
    public static final String NOTIFY_PAUSE = "pure_music.kunminx.pause";
    public static final String NOTIFY_PLAY = "pure_music.kunminx.play";
    public static final String NOTIFY_PREVIOUS = "pure_music.kunminx.previous";

    public void onReceive(Context context, Intent intent) {
        KeyEvent keyEvent;
        if (Objects.equals(intent.getAction(), "android.intent.action.MEDIA_BUTTON")) {
            if (intent.getExtras() != null && (keyEvent = (KeyEvent) intent.getExtras().get("android.intent.extra.KEY_EVENT")) != null && keyEvent.getAction() == 0) {
                int keyCode = keyEvent.getKeyCode();
                if (keyCode == 79 || keyCode == 85) {
                    EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PLAY));
                } else if (keyCode == 87) {
                    EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT));
                } else if (keyCode == 88) {
                    EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT_PREPARE));
                } else if (keyCode == 126) {
                    EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PLAY));
                } else if (keyCode == 127) {
                    EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PAUSE));
                }
            }
        } else if (((String) Objects.requireNonNull(intent.getAction())).equals("pure_music.kunminx.play")) {
            EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PLAY));
        } else if (intent.getAction().equals("pure_music.kunminx.pause") || intent.getAction().equals("android.media.AUDIO_BECOMING_NOISY")) {
            EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PAUSE));
        } else if (intent.getAction().equals("pure_music.kunminx.next")) {
            EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT));
        } else if (!intent.getAction().equals("pure_music.kunminx.close") && intent.getAction().equals("pure_music.kunminx.previous")) {
            EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT_PREPARE));
        }
    }
}
